/*
 * @Author: liaoxing
 * @Date: 2021-08-20 17:37:18
 * @LastEditors: liaoxing
 * @LastEditTime: 2021-08-20 17:37:19
 * @Description: file content
 * @FilePath: \数据中心\src\utils\cookies.js
 */
export default {
  setCookie (name, value) {
    var Days = 30
    var exp = new Date()
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 30)
    document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString()
  },
  getCookie (name) {
    let cookieReg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
    let cookieArray = document.cookie.match(cookieReg)
    if (cookieArray) {
      return unescape(cookieArray[2])
    } else {
      return null
    }
  },
  getCookieName (name) {
    let cookieReg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
    let cookieArray = document.cookie.match(cookieReg)
    if (cookieArray) {
      return (cookieArray[2])
    } else {
      return null
    }
  },
  deleteCookie (name) {
    let date = new Date()
    date.setTime(date.getTime() - 10000)
    document.cookie = name + '=0;expires=' + date.toUTCString()
  }
}